<template>
    <div class="root">
        <div class="container">
            <div class="part">
                <p>本次学习内容</p>
                <input type="text" v-model="domsg.task" placeholder="如: 背单词...">
            </div>
            <div class="part">
                <p>设置学习时间</p>
                <input type="text" v-model="domsg.time" placeholder="如: 30 (单位分钟)">
            </div>
            <button :disabled="flag" @click="tostudy">开始学习</button>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            domsg:{
                task:'',
                time:null
            },
            flag:true
        }
    },
    methods:{
        tostudy(){
            this.$store.state.taks = this.domsg.task
            this.$store.state.messiontime = this.domsg.time
            this.$router.push('/selfRoom')
        },
        cndo(){
            if(this.domsg.task!==''&&this.domsg.time!==''){
                this.flag = false
            }else{
                this.flag = true
            }
        }
    },
    computed:{
        
    },
    watch:{
        'domsg.task':function(newval,oldval){
            if(newval !== ''){
                this.cndo()
            }
        },
        'domsg.time':function(newval,oldval){
            if(newval !== ''){
                this.cndo()
            }
        }
    }
}
</script>

<style lang="less" scoped>
    .root{
        width: 100%;
        height: 82.2%;
        background-color: rgb(247, 248, 252);
        .container{
            width: 92%;
            height: 100%;
            // background-color: royalblue;
            .part{
                width: 100%;
                p{
                    color:rgb(82, 81, 112);
                }
                input{
                    width: 100%;
                    height: 38px;
                    border-radius: 10px;
                    padding-left: 10px;
                    outline: none;
                    border: none;
                    margin-top: 5px;
                }
            }
            .part:nth-child(2){
                margin-top: 8px;
            }
            button{
                width: 100%;
                height: 45px;
                margin-top: 10px;
                background-color: rgb(78, 147, 242);
                border-radius: 10px;
                border:none;
                outline: none;
                color: white;
                font-size: 16px;
                letter-spacing: 1px;
            }
        }
    }
</style>
